package core
{
	import mx.controls.Alert;
	
	import tools.generators.GUID;
	import tools.collections.HashMap;
	import tools.collections.HashMapEntry;

	/**
	 * 
	 */
	public class PutIoLoaderList
	{
		private static const USE_WEAK_REFERENCES:Boolean = false;
		
		private var loaders:HashMap = new HashMap(USE_WEAK_REFERENCES);
				
		/**
		 * Add loader on list
		 * 
		 * @param loader Loader ton add
		 */
		public function addLoader(loader:PutIoLoader):String
		{
			//Generate unique ID
			var id:String = GUID.create();
			//Stick ID on loader
			loader.id = id;
			//Put on hashmap
			loaders.put(id, loader);
			
			return id;
		}
		
		/**
		 * Retrieve a loader
		 * 
		 * @param id Loader ID
		 */
		public function getLoader(id:String):PutIoLoader
		{
			return loaders.getValue(id) as PutIoLoader;
		}
		
		/**
		 * Delete loader from list
		 * 
		 * @param id Loader ID
		 */
		public function removeLoader(id:String):void
		{
			loaders.remove(id);
		}
	}
}